Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux.DataView', jypath + '/static/ext/src/ux/DataView');
Ext.require([
    'Ext.data.*',
    'Ext.util.*',
    'Ext.view.View',
    'Ext.ux.DataView.DragSelector',
    'Ext.ux.DataView.LabelEditor'
]);
Ext.onReady(function(){
	var switchTab = 1;
	var treeStoreJson = null;
	$.ajax({
		type : "POST",
		url : jypath + "/marketing/priceScheme/treeNodeList?resourcesCode=menu_0003_0001&resourcesName=resName_pro_list",
		dataType : "json",
		async : false,
		success : function(data) {
			treeStoreJson = data;
		}
	});
	var store = Ext.create('Ext.data.TreeStore', {
		root : {
			expanded : true,
			children : treeStoreJson
		}
	});
	var clickListener = function(node, event) {
		var id = event.data.id;
		console.log("===============");
		switchTab = $("#tab_type").val();
		if(switchTab==1){
			Ext.getCmp("allInfoBody").removeAll();
			Ext.getCmp("detailInfoBody").removeAll();
			var roomSwitchModel=Ext.create('component.room.switchTab',{
				treeId: id
			});
			Ext.getCmp("detailInfoBody").add(roomSwitchModel);
		}else{
			Ext.getCmp("centerBody").removeAll();
			var roomSwitchList=Ext.create('component.room.switch',{
				treeId: id
			});
			center.add(roomSwitchList);
		}
	}
	var treePanel = Ext.create('Ext.tree.Panel', {
		id : 'menuTree',
		region : 'west',
		split : true,
		title : '项目树',
		width : 220,
		stateId : 'appnav',
		stateful : true,
		margins : '2 0 0 0',
		collapsible : true,
		animCollapse : true,
		xtype : 'treepanel',
		rootVisible : false,
		store : store,
		listeners : {
			itemclick : clickListener
		}
		
	});
	
	
	//创建一个动态区域
	var center = Ext.create('Ext.Panel', {
		region:'center',
		layout: 'anchor', 
        title: '房源销控',
        id:'centerBody',
        frame: true, 
        autoScroll: true, 
        defaults: {  
            bodyStyle: 'background-color: #FFFFFF; padding: 3px'  
        },
        items:[
             createTop(),createButton()  
          ]
	});
	
    var viewport = Ext.create('Ext.Viewport', {
		layout : 'border',
		items : [ treePanel,center]
	});
});

	